<style lang="scss" scoped>
    @import '@/assets/css/index';
    .poster{
        padding: 10px;
        @include page();
		position: relative;
		// background:url('https://vkceyugu.cdn.bspapp.com/VKCEYUGU-d6d772e8-edba-4e51-a6a3-850f3326ab0d/e8091537-1a4f-4e2a-93f6-2921d29f37ea.jpg') no-repeat;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		background-position: center;
        .qrcode{
			position: absolute;
			bottom: 25px;
			right: 20px;
		}
    }
</style>
<template>
  <div class="poster" :style="{backgroundImage:`url(${promoterConfig.poster})`}">
      <!-- <div>推广海报</div> -->
	  <!-- 二维码 -->
	  <canvas class="qrcode" id="qrCode-canvas"></canvas>
  </div>
</template>

<script>
import { Button, Cell } from 'vant'
import {myMixins} from "@/assets/js/mixins.js"
import QRCode from "qrcode";
//已引入vuex
import { mapGetters,mapActions } from 'vuex'
export default {
	mixins:[myMixins],
    name: 'GetMoney',
    components: {
        [Button.name]: Button,
        [Cell.name]: Cell
    },
    data () {
        return {
            poster:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-d6d772e8-edba-4e51-a6a3-850f3326ab0d/e8091537-1a4f-4e2a-93f6-2921d29f37ea.jpg'
        }
    },
	computed: {
		...mapGetters(['promoterConfig','promoterItema'])
	},
	created() {
		this.GET_promoterConfig()
		const params = {
			openid: ''
		}
		if (process.env.NODE_ENV == "production") {
			//线上环境
			params.openid = localStorage.getItem("OPENID") || "没获取到";
			
			} else {
			params.openid = this.$store.state.openid;
		}
		this.GET_promoterItema(params)
	},
    mounted () {
        // this.myInfo = this.$store.state.userInfo
        // if(!this.myInfo){
        //     this.$router.go(-1)
        //     return
        // }
		this.$nextTick(()=>{
			this.createQrcode()
		},200)
    },
    methods: {
		...mapActions(['GET_promoterConfig', 'GET_promoterItema']),
		// getConfigItemcommission() {
		// 	this.$request.getConfigItemcommission().then(res=>{
		// 		if(res.ret == 200) {
		// 			this.poster = res.data.value.poster
		// 		}
		// 	})
		// },
        toApplyView() {
            this.$router.push('/promoter/ApplyGetMoney')
        },
        getMoneyRecord() {
          this.recordShow = !this.recordShow
        },
		createQrcode() {
		  // item.href||
		  let href = `${location.protocol}//${location.hostname}${
		    location.href.indexOf("addons") > -1
		      ? "/addons/youmi_activitys/public"
		      : ""
		  }/mobile/index.html#/my?promoter_id=${this.promoterItema.id}`;
		  console.log(href);
		  let canvas = document.getElementById("qrCode-canvas");
		  QRCode.toCanvas(canvas, href, (error) => {
		    if (error) {
		      //console.log(error)
		    } else {
		      canvas.style.width = "12rem";
		      canvas.style.height = "12rem";
		    }
		  });
		},
    }
}
</script>